package com.intretech.umsin.demo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.intretech.umsin.common.annotation.Dict;
import com.intretech.umsin.datasource.entity.BaseEntity;

import java.time.LocalDateTime;

/**
 * @version V1.0
 * @ClassName: User
 * @Description: User 服务实现
 * @author: 李启联
 * @date: 2022-04-19 16:34
 * @Copyright: Copyright (c) 2022
 */
@TableName("user")
public class UserEntity extends BaseEntity {
    // 名称
    @TableField(value = "name")
    private String name;
    // 年龄
    @TableField(value = "age")
    private Integer age;
    // 性别
    @TableField(value = "sex")
    @Dict(dicCode = "sex")
    private Integer sex;
    // 生日
    @TableField(value = "birthday")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private java.time.LocalDateTime birthday;

    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
    }
    public Integer getAge(){
        return this.age;
    }
    public void setAge(Integer age){
        this.age = age;
    }
    public Integer getSex(){
        return this.sex;
    }
    public void setSex(Integer sex){
        this.sex = sex;
    }
    public java.time.LocalDateTime getBirthday(){
        return this.birthday;
    }
    public void setBirthday(java.time.LocalDateTime birthday){
        this.birthday = birthday;
    }

    public UserEntity(){
    }

    public UserEntity(String name, Integer age, Integer sex, LocalDateTime birthday) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.birthday = birthday;
    }

    @Override
    public String toString(){
        return " User ["
                +" name = " +name +" ,"
                +" age = " +age +" ,"
                +" sex = " +sex +" ,"
                +" birthday = " +birthday
                +" ]";
    }
}
